var prefix = api + "/admin/dict/item";
var oper = getQueryString('oper')
var id = getQueryString('id')
var pid = getQueryString('pid')
var type = getQueryString('type')
$(function() {
	$('#oper').val(oper)
	$("#typeShow").val(type);
	$("#type").val(type);
	$("#dictId").val(pid);
	if (oper === 'edit') {
		dictItemDetail(id)
	}

	jQuery.validator.addMethod("format", function (value, element) {
		var account = /^[a-zA-Z0-9_]*$/;
		return account.test(value);
	}, "只支持字母、数字、下划线");
});

function dictItemDetail(id){
	$.operate.get(api + '/admin/dict/item/' + id, function (res) {
		res.data.oper = oper
		applyDrawing('#editForm',res.data)
	}, false)
}

$("#editForm").validate({
	onkeyup : false,
	rules : {
		value: {
			required: true,
			format: true
		},
		label: {
			required: true,
		},
		description: {
			required: true,
		},
		sort : {
			required: true,
			digits:true
		},
	},
	messages: {
		value: {
			required: "请输入数据值",
		},
		label: {
			required: "请输入标签名",
		},
		description: {
			required: "请输入字典描述",
		},
		sort : {
			required: "请输入排序",
		},
	},
	focusCleanup : true
});
		

function submitHandler() {
	if ($.validate.form()) {
		$.common.ajaxCommitForm($('#editForm'),false);
    	return false;
	}
}